package com.zr.java8.atomic;

import java.util.concurrent.atomic.AtomicInteger;

public class Solution {
    public static void main(String[] args) {
        AtomicInteger atomicInteger = new AtomicInteger(0);

        if (atomicInteger.compareAndSet(0, 1)) {
            System.out.println(atomicInteger.get());
        }

        if (atomicInteger.compareAndSet(0, 0)) {
            System.out.println(atomicInteger.get());
        }

        if (atomicInteger.compareAndSet(1, 0)) {
            System.out.println(atomicInteger.get());
        }

        System.out.println(atomicInteger.get());
    }
}
